<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
          <div class="table-operator">
            <rx-button alias="sysTimeZoneConfigAdd" :butn-icon="'plus'" :butn-type="'primary'" :show-no-right="true" @click="add">{{$ti18('rxList.newBtn','新建')}}</rx-button>
            <a-dropdown v-if="editEnable && selectedRowKeys.length > 0 || removeEnable && selectedRowKeys.length > 0">
              <a-button style="margin-left: 8px"> {{$ti18('rxList.moreBtn','更多')}} <a-icon type="down" /> </a-button>
              <a-menu slot="overlay">
                <a-menu-item key="1" v-if="editEnable && selectedRowKeys.length > 0" alias="sysTimeZoneConfigEdit" :butn-icon="'edit'"
                             :butn-type="'primary'" :show-no-right="false" @click="editOne"><a-icon type="edit"  />{{$ti18('rxList.editBtn','编辑')}}</a-menu-item>
                <a-menu-item key="2" v-if="removeEnable && selectedRowKeys.length > 0" alias="sysTimeZoneConfigDelete" :butn-icon="'delete'" :butn-type="'danger'"
                             :show-no-right="false" @click="delByIds(selectedRowKeys)"><a-icon type="delete" />{{$ti18('rxList.delBtn','删除')}}</a-menu-item>
              </a-menu>
            </a-dropdown>
          </div>
          <span class="search-btn-box">
                <span class="search-btn" @click="searchshow"><i class="iconfont iconguolv"></i>{{$ti18('rxList.leachBtn','过滤')}}</span>
           </span>
        </div>
        <div slot="searchbar" btnalign="right"  v-if="fitSearch" @search="search" @cancel="cancel" @close="close">
          <a-form layout="vertical">
                <a-form-item :label="i18n('form.languageType','语言类型')">
                    <a-input :placeholder="i18n('form.languageType','语言类型','input')" v-model="queryParam.Q_LANGUAGE_TYPE__S_LK"/>
                </a-form-item>
                <a-form-item :label="i18n('form.timeZoneId','时区ID')">
                    <a-input :placeholder="i18n('form.timeZoneId','时区ID','input')" v-model="queryParam.Q_TIME_ZONE_ID__S_LK"/>
                </a-form-item>
                <a-form-item :label="i18n('form.timeZoneName','时区名称')">
                    <a-input :placeholder="i18n('form.timeZoneName','时区名称','input')" v-model="queryParam.Q_TIME_ZONE_NAME__S_LK"/>
                </a-form-item>
              <a-form-item :label="i18n('form.isDisable','是否可用')">
                  <a-select :placeholder="i18n('form.isDisable','是否可用')" v-model="queryParam['Q_IS_DISABLE__S_EQ']"
                            :allowClear="true">
                      <a-select-option value="YES">{{i18n('form.enabled','可用')}}</a-select-option>
                      <a-select-option value="NO">{{i18n('form.disable','禁用')}}</a-select-option>
                  </a-select>
              </a-form-item>
          </a-form>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-system/system/core/sysTimeZoneConfig/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                id-field="id"
                @selectChange="onSelectChange"
        >
            <span slot="isDisable" slot-scope="{ text, record }">
                        <a-tag :color="isDisableMap[text].color">
                        <span>{{ isDisableMap[text].text }}</span>
                        </a-tag>
                    </span>
            <span slot="action" slot-scope="{ text, record }" class="actionIcons">
                        <span @click="edit(record)">{{$ti18('rxList.editBtn','编辑')}}</span>
                        <span @click="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
                    </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import SysTimeZoneConfigApi from '@/api/system/core/sysTimeZoneConfig'
  import SysTimeZoneConfigEdit from './SysTimeZoneConfigEdit'
  import {BaseList,RxFit,RxGrid } from "@lowcode/jpaas-common-lib";
  export default {
    name: 'SysTimeZoneConfigList',
    mixins: [BaseList],
    components: {
      RxFit
    },
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.languageType','语言类型'), dataIndex: 'languageType', width: 100},
          {title: this.i18n('form.timeZoneId','时区ID'), dataIndex: 'timeZoneId', width: 100},
          {title: this.i18n('form.timeZoneName','时区名称'), dataIndex: 'timeZoneName', width: 100},
          {title: this.i18n('form.isDisable','是否可用'), dataIndex: 'isDisable', width: 100, scopedSlots: {customRender: 'isDisable'}},
          {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:SysTimeZoneConfigEdit,
        comment:this.i18n('list.comment','时区配置'),
        widthHeight:['800px','600px'],
        fitSearch:false,
        isDisableMap: {
            "NO": {color: 'red', text: this.i18n('form.disable','禁用')},
            "YES": {color: 'green', text: this.i18n('form.enabled','可用')}
        },
      }
    },
    methods:{
            i18n(name,text,key){
                return this.$ti18(name,text,"SysTimeZoneConfig",key);
            },
            delById(ids){
                return SysTimeZoneConfigApi.del({ ids: ids.join(',') });
            },
            getListByParams(parameter){
                return SysTimeZoneConfigApi.query(parameter)
            }

    }
  }
</script>
<style scoped>
  .table-operator {
    padding:4px;
  }
  .table-operator button {
    margin:2px;
  }
</style>

